﻿<Window x:Class="iControl.Windows.QuickSelectWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:properties="clr-namespace:iControl.Properties"
	xmlns:iControl="clr-namespace:iControl.Controls"
	xmlns:ic="clr-namespace:iControl"
    Title="Quick Select - iControl" Height="420" Width="450" AllowsTransparency="True" 
    WindowStyle="None" FontFamily="Tahoma" Opacity="1" Background="#00FFFFFF" Topmost="True" 
	Icon="..\Images\iControlIcon.ico" WindowStartupLocation="CenterScreen"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	mc:Ignorable="d" 
	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna" ResizeMode="NoResize" KeyDown="Window_KeyDown" xmlns:iControl1="clr-namespace:iControl" x:Name="window" 
    ShowInTaskbar="True" Activated="Window_Activated" Deactivated="Window_Deactivated">
    <Window.Resources>

        <!-- Show Window Animation -->
        <Storyboard x:Key="ShowAnimation">
            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="{x:Null}" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                <SplineDoubleKeyFrame KeySpline="0,0,0.5,1" KeyTime="00:00:00.2000000" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

        <!-- XClose Button Style -->
        <Style x:Key="CloseXButtonStyle" TargetType="{x:Type Button}">
            <Setter Property="FocusVisualStyle" Value="{DynamicResource ButtonFocusVisual}"/>
            <Setter Property="Background" Value="{DynamicResource ButtonNormalBackgroundFill}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource ButtonBorder}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <ControlTemplate.Resources>
                            <Storyboard x:Key="MouseOverAnimation">
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                            <Storyboard x:Key="MouseOutAnimation">
                                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.BitmapEffect).(OuterGlowBitmapEffect.Opacity)">
                                    <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
                                </DoubleAnimationUsingKeyFrames>
                            </Storyboard>
                        </ControlTemplate.Resources>
                        <Image Source="..\Images\Skin\Close.png" x:Name="image">
                            <Image.BitmapEffect>
                                <OuterGlowBitmapEffect GlowColor="#FFFF0000" Opacity="0"/>
                            </Image.BitmapEffect>
                        </Image>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="BitmapEffect" TargetName="image">
                                    <Setter.Value>
                                        <OuterGlowBitmapEffect GlowColor="#FFFF0000" Opacity="1"/>
                                    </Setter.Value>
                                </Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <SolidColorBrush x:Key="ListBorder" Color="#FFA5ACB2"/>
        <Style x:Key="SearchBoxStyle" TargetType="{x:Type TextBox}">
        	<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
        	<Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
        	<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        	<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
        	<Setter Property="BorderThickness" Value="1"/>
        	<Setter Property="HorizontalContentAlignment" Value="Left"/>
        	<Setter Property="Padding" Value="2"/>
        	<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        	<Setter Property="AllowDrop" Value="true"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="{x:Type TextBox}">
        				<Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2">
        					<Grid Width="267.667" Height="19">
        						<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,0,22,0"/>
        						<Button HorizontalAlignment="Right" VerticalAlignment="Center" Content="Button" Width="16" Height="16" Margin="0,0,2,0" x:Name="btnClearSearchBox" Style="{DynamicResource ClearSearchBoxButtonStyle}" Click="btnClearSearchBox_Click"/>
        					</Grid>
        				</Border>
        				<ControlTemplate.Triggers>
        					<Trigger Property="IsEnabled" Value="false">
        						<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
        						<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
        					</Trigger>
        				</ControlTemplate.Triggers>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
        <Style x:Key="ClearSearchBoxButtonStyle" TargetType="{x:Type Button}">
        	<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        	<Setter Property="Background" Value="{StaticResource ButtonNormalBackgroundFill}"/>
        	<Setter Property="BorderBrush" Value="{StaticResource ButtonBorder}"/>
        	<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        	<Setter Property="HorizontalContentAlignment" Value="Center"/>
        	<Setter Property="VerticalContentAlignment" Value="Center"/>
        	<Setter Property="Template">
        		<Setter.Value>
        			<ControlTemplate TargetType="{x:Type Button}">
        				<Grid Margin="1,1,1,1">
        					<Ellipse Fill="#FFFFFFFF" Stroke="#FFCCCCCC" StrokeThickness="1" x:Name="ellipse"/>
        					<Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{Binding Path=Stroke, ElementName=ellipse, Mode=Default}" VerticalAlignment="Stretch" Data="M4,13.40625L11.8195833333333,2.78125" RenderTransformOrigin="0.5,0.5" Margin="4,4,4,4">
        						<Path.RenderTransform>
        							<TransformGroup>
        								<ScaleTransform ScaleX="-1" ScaleY="1"/>
        								<SkewTransform AngleX="0" AngleY="0"/>
        								<RotateTransform Angle="0"/>
        								<TranslateTransform X="0" Y="0"/>
        							</TransformGroup>
        						</Path.RenderTransform>
        					</Path>
        					<Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{Binding Path=Stroke, ElementName=ellipse, Mode=Default}" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Data="M4,13.40625L11.8195833333333,2.78125" HorizontalAlignment="Stretch" Margin="4,4,4,4">
        						<Path.RenderTransform>
        							<TransformGroup>
        								<ScaleTransform ScaleX="1" ScaleY="1"/>
        								<SkewTransform AngleX="0" AngleY="0"/>
        								<RotateTransform Angle="0"/>
        								<TranslateTransform X="0" Y="0"/>
        							</TransformGroup>
        						</Path.RenderTransform>
        					</Path>
        				</Grid>
        				<ControlTemplate.Triggers>
        					<Trigger Property="IsMouseOver" Value="True">
        						<Setter Property="Stroke" TargetName="ellipse" Value="#FF6C6C6C"/>
        					</Trigger>
        					<Trigger Property="IsKeyboardFocused" Value="true"/>
        					<Trigger Property="ToggleButton.IsChecked" Value="true"/>
        					<Trigger Property="IsEnabled" Value="false">
        						<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
        					</Trigger>
        				</ControlTemplate.Triggers>
        			</ControlTemplate>
        		</Setter.Value>
        	</Setter>
        </Style>
        <DataTemplate x:Key="PlaylistItemTemplate">
        	<StackPanel Orientation="Horizontal">
        		<iControl:Rating x:Name="trackRating" Width="65" HorizontalAlignment="Left" VerticalAlignment="Stretch" Margin="4,0,0,0" RatingValue="{Binding Path=Rating, Mode=Default, FallbackValue=3}" IsEnabled="False" >
        			<iControl:Rating.Style>
        				<Style TargetType="{x:Type iControl:Rating}">
        					<Setter Property="Template">
        						<Setter.Value>
        							<ControlTemplate TargetType="{x:Type iControl:Rating}">
        								<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
        									<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
        								</Border>
        							</ControlTemplate>
        						</Setter.Value>
        					</Setter>
        				</Style>
        			</iControl:Rating.Style>
        		</iControl:Rating>
        		<Label Content="{Binding Path=TrackName, Mode=Default, FallbackValue=\{TrackName\}}" Margin="8,0,0,0" VerticalAlignment="Center"/>
        	</StackPanel>
        </DataTemplate>
        <Storyboard x:Key="HideAnimation">
        	<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="{x:Null}" Storyboard.TargetProperty="(UIElement.Opacity)">
        		<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
        	</DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </Window.Resources>
    <Window.Triggers >
    </Window.Triggers>
    <!-- Window Body -->
    <Border Margin="0,0,0,0" BorderBrush="#CAFFFFFF" BorderThickness="1,1,1,1" CornerRadius="3,3,3,3" Background="#E5317699" MouseLeftButtonDown="DragWindow">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="27"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="6"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="6"/>
            </Grid.ColumnDefinitions>
            <Canvas HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="1" Grid.Row="0" d:LayoutOverrides="GridBox" Grid.RowSpan="1" Grid.ColumnSpan="1" Margin="0,0,43,0">
                <Button x:Name="btnCloseX" Style="{DynamicResource CloseXButtonStyle}" Width="44" Height="18" Content="Button" Click="btnCloseX_Click"/>
            </Canvas>
            <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="1" BorderBrush="#FFDAE2E6" BorderThickness="1,1,1,1" CornerRadius="3,3,3,3" Margin="0,0,0,6">
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FF9ED5F0" Offset="0"/>
                        <GradientStop Color="#FFB6D1E1" Offset="1"/>
                        <GradientStop Color="#FFACBCC5" Offset="0.504"/>
                    </LinearGradientBrush>
                </Border.Background>
                <Grid x:Name="pnlMain" Margin="8,4,8,8">
                	<Grid.RowDefinitions>
                		<RowDefinition Height="30"/>
                		<RowDefinition Height="*"/>
                	</Grid.RowDefinitions>
                	<StackPanel Orientation="Horizontal">
                		<Label Content="{x:Static properties:Resources.QuickSelectWindow_FilterText}" VerticalContentAlignment="Center" Height="30" Padding="8,5,5,5" Margin="-7,0,0,0"/>
                    
                		<TextBox Width="270.333" Text="" TextWrapping="Wrap" Height="22" Style="{DynamicResource SearchBoxStyle}" x:Name="txtFilter" TextChanged="txtFilter_TextChanged" MaxLength="250"/>
                		<Button Content="Search Library" Height="21" Margin="4,0,0,0" x:Name="btnSearchLibrary" Click="btnSearchLibrary_Click"/>
                        <iControl:Marquee x:Name="pbLoading" Width="15" Height="15" HorizontalAlignment="Right" Margin="5,0,0,0" Visibility="Hidden"  />
                    </StackPanel>
                	<ListBox IsSynchronizedWithCurrentItem="True" Grid.Row="1" x:Name="lstPlaylist" ItemTemplate="{DynamicResource PlaylistItemTemplate}" BorderBrush="#FFFFFFFF">
                		<ListBox.ItemsPanel>
                			<ItemsPanelTemplate>
                				<VirtualizingStackPanel IsItemsHost="True"/>
                			</ItemsPanelTemplate>
                		</ListBox.ItemsPanel>
						<ListBox.ItemContainerStyle>
							<Style TargetType="{x:Type ListBoxItem}">
								<EventSetter Event="MouseDoubleClick" Handler="PlaylistItem_DoubleClick" />
							</Style>
						</ListBox.ItemContainerStyle>
                		<ListBox.Background>
                			<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                				<GradientStop Color="#FF9FD3ED" Offset="0"/>
                				<GradientStop Color="#FFB6D1E1" Offset="1"/>
                			</LinearGradientBrush>
                		</ListBox.Background>
                	</ListBox>
                </Grid>

            </Border>
            <Image HorizontalAlignment="Left" Width="20" Grid.Column="1" Source="..\Images\iControlIcon24.png" Stretch="Fill" VerticalAlignment="Center" Height="20" Margin="0,0,0,0"/>
            <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" TextWrapping="Wrap" Grid.Row="0" d:LayoutOverrides="HorizontalAlignment, GridBox" Grid.Column="1" Margin="27,0,0,0" Foreground="#FFFFFFFF" FontFamily="Tahoma" x:Name="lblWindowTitle"/>
        </Grid>
    </Border>
</Window>
